home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / net / sun4.md / netIEInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  29.0 KB  |  861 lines

  1. /*
  2.  * netIEInt.h --
  3.  *
  4.  *    External definitions for the Intel on-board Ethernet controller.  See
  5.  *      the Intel "LAN Components User's Manual" from 1984 for a 
  6.  *    description of the definitions here.  One note is that the Intel chip 
  7.  *    is wired in byte swapped order.  Therefore all definitions in here are 
  8.  *    byte swapped from the ones in the user's manual.
  9.  *
  10.  * Copyright 1985, 1988 Regents of the University of California
  11.  * Permission to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose and without
  13.  * fee is hereby granted, provided that the above copyright
  14.  * notice appear in all copies.  The University of California
  15.  * makes no representations about the suitability of this
  16.  * software for any purpose.  It is provided "as is" without
  17.  * express or implied warranty.
  18.  *
  19.  *
  20.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/net/sun4.md/netIEInt.h,v 9.7 91/09/10 18:41:07 rab Exp $ SPRITE (Berkeley)
  21.  */
  22.  
  23. #ifndef _NETIEINT
  24. #define _NETIEINT
  25.  
  26. #include <netInt.h>
  27.  
  28. /*
  29.  * Defined constants:
  30.  *
  31.  * NET_IE_CONTROL_REG_ADDR    The address of the control register for the 
  32.  *                ethernet chip.
  33.  * NET_IE_SYS_CONF_PTR_ADDR     Place where the system configuration pointer 
  34.  *                must start. 
  35.  * NET_IE_DELAY_CONST        Number of loops to poll the ethernet chip
  36.  *                before giving up. (see NET_IE_DELAY())
  37.  * NET_IE_CHUNK_SIZE        The number of bytes that memory is allocated
  38.  *                in.
  39.  * NET_IE_MEM_SIZE              Amount of memory to set aside for the control 
  40.  *                blocks.
  41.  * NET_IE_NUM_RECV_BUFFERS      The number of buffers that we have to receive
  42.  *                   packets in.
  43.  * NET_IE_NUM_XMIT_BUFFERS      The number of buffer descriptors that are used
  44.  *                   for a transmitted packet.
  45.  * NET_IE_RECV_BUFFER_SIZE      The size of each receive buffer.
  46.  * NET_IE_MIN_DMA_SIZE        The smallest buffer that can be use for DMA.
  47.  *                If a piece of a message is smaller than this
  48.  *                then it gets copied to other storage and
  49.  *                made the minimum size.
  50.  * NET_IE_NULL_RECV_BUFF_DESC     The value that is used by the controller to 
  51.  *                indicate that a header points to no data.
  52.  * NET_IE_NUM_XMIT_ELEMENTS     The number of elements to preallocate for the 
  53.  *                   retransmission queue.
  54.  */
  55.  
  56. #ifdef sun3
  57. #define NET_IE_CONTROL_REG_ADDR        0xfe0c000
  58. #define NET_IE_SYS_CONF_PTR_ADDR    0xffffff6
  59. #define    NET_IE_DELAY_CONST        400000
  60. #endif /* sun3 */
  61.  
  62.  
  63. #ifdef sun2
  64. #define NET_IE_CONTROL_REG_ADDR        0xee3000
  65. #define NET_IE_SYS_CONF_PTR_ADDR    0xfffff6
  66. #define    NET_IE_DELAY_CONST        (400000>>2)
  67. #endif /* sun2 */
  68.  
  69. #ifdef sun4
  70. #define NET_IE_CONTROL_REG_ADDR        0xffd0c000
  71. #define NET_IE_SYS_CONF_PTR_ADDR    0xfffffff4
  72. #define    NET_IE_DELAY_CONST        (400000<<2)
  73. #endif /* sun4 */
  74.  
  75. #define    NET_IE_CHUNK_SIZE        32
  76. #define    NET_IE_MEM_SIZE            3072
  77. #ifdef sun4
  78. #define    NET_IE_NUM_RECV_BUFFERS        32
  79. #else
  80. #define    NET_IE_NUM_RECV_BUFFERS        18
  81. #endif
  82. #define    NET_IE_NUM_XMIT_BUFFERS        20
  83. #define    NET_IE_RECV_BUFFER_SIZE        NET_ETHER_MAX_BYTES
  84. #define    NET_IE_MIN_DMA_SIZE        12
  85. #define    NET_IE_NULL_RECV_BUFF_DESC    0xffff
  86. #define    NET_IE_NUM_XMIT_ELEMENTS    32
  87.  
  88. /*
  89.  * Macros to manipulate the chip.
  90.  *
  91.  * NET_IE_CHIP_RESET        Reset the chip.
  92.  * NET_IE_CHANNEL_ATTENTION    Get the attention of the chip.
  93.  * NET_IE_DELAY            Delay until the microsecond limit is up or
  94.  *                until the condition is true.
  95.  * NET_IE_CHECK_SCB_CMD_ACCEPT    Check to see if the command has been accepted.
  96.  * NET_IE_ADDR_FROM_SUN_ADDR    Change a SUN address to an intel address.
  97.  * NET_IE_ADDR_TO_SUN_ADDR    Change an intel address to a SUN address.
  98.  */
  99.  
  100. #define NET_IE_CHIP_RESET(statePtr) \
  101.     (*(volatile char *) statePtr->controlReg = 0)
  102. #define NET_IE_CHANNEL_ATTENTION(statePtr) \
  103.     { \
  104.         NetBfByteSet(statePtr->controlReg, ChannelAttn, 1); \
  105.         NetBfByteSet(statePtr->controlReg, ChannelAttn, 0); \
  106.     }
  107.  
  108. #define NET_IE_DELAY(condition) \
  109.     { \
  110.         register int i = (NET_IE_DELAY_CONST); \
  111.         while (i > 0 && !(condition)) { \
  112.             i--; \
  113.         } \
  114.         if (!(condition)) { \
  115.         printf("Delay %s:%d failed.\n", __FILE__, __LINE__); \
  116.         } \
  117.     }
  118.  
  119. #define    NET_IE_CHECK_SCB_CMD_ACCEPT(scbPtr) \
  120.     if (*(short *) &(scbPtr->cmdWord) != 0) { \
  121.     NetIECheckSCBCmdAccept(scbPtr); \
  122.     }
  123.  
  124. #define NET_IE_ADDR_FROM_SUN_ADDR(src, dest) { \
  125.     union { \
  126.         int     i; \
  127.         char    ch[4]; \
  128.     } addrTo, addrFrom; \
  129.     addrFrom.i = src; \
  130.     addrTo.ch[0] = addrFrom.ch[3]; \
  131.     addrTo.ch[1] = addrFrom.ch[2]; \
  132.     addrTo.ch[2] = addrFrom.ch[1]; \
  133.     addrTo.ch[3] = 0; \
  134.     dest = addrTo.i; \
  135. }
  136.  
  137. #define    NET_IE_ADDR_TO_SUN_ADDR(src, dest) { \
  138.     union { \
  139.     int     i; \
  140.     char    ch[4]; \
  141.     } addrTo, addrFrom; \
  142.     addrFrom.i = src; \
  143.     addrTo.ch[0] = 0; \
  144.     addrTo.ch[1] = addrFrom.ch[2]; \
  145.     addrTo.ch[2] = addrFrom.ch[1]; \
  146.     addrTo.ch[3] = addrFrom.ch[0]; \
  147.     dest = addrTo.i; \
  148. }
  149.  
  150. /*
  151.  * System configuration pointer.  Must be at 0xfffff6 in chip's address space.
  152.  */
  153.  
  154. typedef struct {
  155. #ifdef sun4
  156.     short padding;    /* Since structures can't start on a half-word boundry
  157.              * on the sun4, we start the structure on a word 
  158.              * boundry and include 2 bytes of padding.
  159.              */
  160. #endif /* sun4 */
  161.     char busWidth;    /* Bus width.  0 => 16 bits.  1 => 8 bits. */
  162.     char filler[5];    /* Unused. */
  163.     int     intSysConfPtr;    /* Address of intermediate system configuration 
  164.                pointer. */
  165. } NetIESysConfPtr;
  166.  
  167. /*
  168.  * Intermediate system configuration pointer.  This specifies the base of the 
  169.  * control blocks and the offset of the System Control Block (SCB).
  170.  */
  171.  
  172. typedef struct {
  173.     char  busy;            /* 1 if initialization in progress. */
  174.     char  filler;        /* Unused. */
  175.     short scbOffset;        /* Offset of the scb. */
  176.     int      base;            /* Base of all control blocks. */
  177. } NetIEIntSysConfPtr;
  178.  
  179. /*
  180.  * The system control block (SCB) status has the following format:
  181.  *
  182.  *typedef struct {
  183.  *    unsigned int             :1;      Must be zero   
  184.  *    unsigned int recvUnitStatus     :3;      Receive unit status   
  185.  *    unsigned int                 :4;      Must be zero   
  186.  *    unsigned int cmdDone        :1;      A command which has its interrupt
  187.  *                       bit set completed.   
  188.  *    unsigned int frameRecvd        :1;      A frame received interrupt has been
  189.  *                       given.   
  190.  *    unsigned int cmdUnitNotActive   :1;  The command unit has left the active
  191.  *                       state.   
  192.  *    unsigned int recvUnitNotReady   :1;  The command unit has left the ready
  193.                        state.   
  194.  *    unsigned int                    :1;      Must be zero.   
  195.  
  196.  *    unsigned int cmdUnitStatus        :3;   Command unit status.   
  197.  *} NetIESCBStatus;
  198.  */
  199. typedef unsigned short NetIESCBStatus[1];
  200.  
  201. #define RecvUnitStatus            0x0103
  202. #define CmdDone                   0x0801
  203. #define FrameRecvd                0x0901
  204. #define CmdUnitNotActive          0x0a01
  205. #define RecvUnitNotReady          0x0b01
  206. #define CmdUnitStatus             0x0d03
  207.  
  208. /*
  209.  * The system control block (SCB) command word has the following format:
  210.  *
  211.  * typedef struct {
  212.  *    unsigned int reset             :1;     Reset the chip.   
  213.  *    unsigned int recvUnitCmd        :3;    The command for the receive unit   
  214.  *    unsigned int              :4;     Unused.   
  215.  *
  216.  *    unsigned int ackCmdDone         :1;     Ack the command completed bit in
  217.  *                         the status word.   
  218.  *    unsigned int ackFrameRecvd      :1;     Ack the frame received bit in the
  219.  *                         the status word.   
  220.  *    unsigned int ackCmdUnitNotActive:1;     Ack that the command unit became
  221.  *                         not active.   
  222.  *    unsigned int ackRecvUnitNotReady:1;     Ack that the receive unit became
  223.  *                         not ready   
  224.  *    unsigned int             :1;     Unused.   
  225.  *    unsigned int cmdUnitCmd         :3;    The command for the command unit   
  226.  *} NetIESCBCommand;
  227.  */
  228. typedef unsigned short NetIESCBCommand[1];
  229.  
  230. #define Reset                     0x0001
  231. #define RecvUnitCmd               0x0103
  232. #define AckCmdDone                0x0801
  233. #define AckFrameRecvd             0x0901
  234. #define AckCmdUnitNotActive       0x0a01
  235. #define AckRecvUnitNotReady       0x0b01
  236. #define CmdUnitCmd                0x0d03
  237.  
  238.  
  239. /*
  240.  * Define the macros to Check and acknowledge the status of the chip.
  241.  *
  242.  * NET_IE_CHECK_STATUS    Extract the 4 status bits out of the scb status word.
  243.  * NET_IE_ACK        Set the bits in the scb command word that acknowledge 
  244.  *            the status bits in the scb status word.
  245.  * NET_IE_TRANSMITTED    Return true if a transit command finished.
  246.  * NET_IE_RECEIVED    Return true if a packet was received.
  247.  */
  248.  
  249. #ifndef lint 
  250. #define    NET_IE_CHECK_STATUS(scbStatus) ((*(short *) &(scbStatus)) & 0xF0)
  251. #else 
  252. #define    NET_IE_CHECK_STATUS(scbStatus) 0
  253. #endif
  254. #define    NET_IE_ACK(scbCommand, status) ((*(short *) &(scbCommand)) |= status)
  255. #define    NET_IE_TRANSMITTED(status)     (status & 0xA0)
  256. #define    NET_IE_RECEIVED(status)        (status & 0x50)
  257.  
  258. /*
  259.  * The system control block.
  260.  */
  261.  
  262. typedef struct {
  263.     NetIESCBStatus    statusWord;
  264.     NetIESCBCommand    cmdWord;
  265.     short            cmdListOffset;
  266.     short            recvFrameAreaOffset;
  267.     short            crcErrors;        /* Count of crc errors. */
  268.     short        alignErrors;        /* Count of alignment errors. */
  269.     short        resourceErrors;        /* Count of correct incoming 
  270.                            packets discarded because
  271.                            of lack of buffer space */
  272.     short        overrunErrors;        /* Count of overrun packets */
  273. } NetIESCB;
  274.  
  275. /*
  276.  * Values for that status of the receive unit (recvUnitStatus).
  277.  */
  278.  
  279. #define NET_IE_RUS_IDLE                0
  280. #define NET_IE_RUS_SUSPENDED        1
  281. #define NET_IE_RUS_NO_RESOURCES        2
  282. #define NET_IE_RUS_READY            4
  283.  
  284. /*
  285.  * Values for that status of the command unit (cmdUnitStatus).
  286.  */
  287.  
  288. #define NET_IE_CUS_IDLE                0
  289. #define NET_IE_CUS_SUSPENDED        1
  290. #define NET_IE_CUS_ACTIVE            2
  291.  
  292. /*
  293.  * Values for the command unit command (cmdUnitCommand).
  294.  */
  295.  
  296. #define    NET_IE_CUC_NOP            0
  297. #define    NET_IE_CUC_START        1
  298. #define    NET_IE_CUC_RESUME        2
  299. #define    NET_IE_CUC_SUSPEND        3
  300. #define    NET_IE_CUC_ABORT        4
  301.  
  302. /*
  303.  * Values for the receive unit command (recvUnitCommand).
  304.  */
  305.  
  306. #define    NET_IE_RUC_NOP            0
  307. #define    NET_IE_RUC_START        1
  308. #define    NET_IE_RUC_RESUME        2
  309. #define    NET_IE_RUC_SUSPEND        3
  310. #define    NET_IE_RUC_ABORT          4
  311.  
  312. /*
  313.  * Generic command block
  314.  */
  315.  
  316. /* 
  317.  * The NetIECommandBlock has the following format:
  318.  *
  319.  * typedef struct {
  320.  *    unsigned int         :8;      Low order bits of status.  
  321.  *    unsigned int cmdDone    :1;      Command done.  
  322.  *    unsigned int cmdBusy    :1;      Command busy.  
  323.  *    unsigned int cmdOK    :1;      Command completed successfully.  
  324.  *    unsigned int cmdAborted    :1;      The command aborted.  
  325.  *    unsigned int        :4;      High order bits of status.  
  326.  *    unsigned int        :5;      Unused.  
  327.  *    unsigned int cmdNumber    :3;      Command number.  
  328.  *    unsigned int endOfList    :1;      The end of the command list.  
  329.  *    unsigned int suspend    :1;      Suspend when command completes.  
  330.  *    unsigned int interrupt    :1;      Interrupt when the command 
  331.  *                       completes.  
  332.  *    unsigned int        :5;      Unused.  
  333.  *   short       nextCmdBlock;      The offset of the next command 
  334.  *                       block.  
  335.  *} NetIECommandBlock;
  336.  */
  337.  
  338. typedef struct {
  339.     unsigned short    bits[2];    /* Control bits.  See below. */
  340.     short           nextCmdBlock;    /* The offset of the next command 
  341.                        block. */
  342. } NetIECommandBlock;
  343.  
  344. #define CmdDone                   0x0801
  345. #define CmdBusy                   0x0901
  346. #define CmdOK                     0x0a01
  347. #define CmdAborted                0x0b01
  348. #define CmdNumber                 0x1503
  349. #define EndOfList                 0x1801
  350. #define Suspend                   0x1901
  351. #define Interrupt                 0x1a01
  352.  
  353. /*
  354.  * Command block commands.
  355.  */
  356.  
  357. #define    NET_IE_NOP        0
  358. #define    NET_IE_IA_SETUP      1
  359. #define    NET_IE_CONFIG        2
  360. #define    NET_IE_MC_SETUP        3
  361. #define    NET_IE_TRANSMIT        4
  362. #define    NET_IE_TDR          5
  363. #define    NET_IE_DUMP         6
  364. #define    NET_IE_DIAGNOSE        7
  365.  
  366. /*
  367.  * The nop command block.
  368.  */
  369.  
  370. typedef struct {
  371.     NetIECommandBlock    cmdBlock;
  372. } NetIENOPCB;
  373.  
  374. /*
  375.  * The individual address setup command block.
  376.  */
  377.  
  378. typedef    struct {
  379.     NetIECommandBlock    cmdBlock;    /* The command block. */
  380.     Net_EtherAddress    etherAddress;    /* The ethernet address. */
  381. } NetIEIASetupCB;
  382.  
  383. /*
  384.  * The multicast address setup command block.
  385.  */
  386.  
  387. typedef    struct {
  388.     NetIECommandBlock    cmdBlock;    /* The command block. */
  389.     short        count;        /* Number of ethernet addresses. */
  390.     Net_EtherAddress    etherAddress;    /* The ethernet address. */
  391. } NetIEMASetupCB;
  392.  
  393. /*
  394.  * The bits of the configure command block have the following format:
  395.  *
  396.  * typedef struct {
  397.  *    NetIECommandBlock    cmdBlock;      The command block.  
  398.  *
  399.  *    unsigned int        :4;      Unused.  
  400.  *    unsigned int byteCount    :4;      Number of configuration bytes.  
  401.  *
  402.  *    unsigned int              :4;      Number of configuration bytes.  
  403.  *    unsigned int fifoLimit    :4;      The fifo limit.  
  404.  *
  405.  *    unsigned int saveBadFrames :1;      Save bad frames.  
  406.  *    unsigned int srdyArdy    :1;      srdy/ardy.  
  407.  *    unsigned int         :6;      Unused.  
  408.  *
  409.  *    unsigned int excLoopback    :1;      External loop back.  
  410.  *    unsigned int intLoopback    :1;      Internal loop back.  
  411.  *    unsigned int preamble    :2;      Preamble length code.  
  412.  *    unsigned int atLoc     :1;      Address and type fields are part  
  413.  *    unsigned int addrLen    :3;      The number of address bytes.  
  414.  *
  415.  *    unsigned int backOff    :1;      Backoff method.  
  416.  *    unsigned int expPrio    :3;      Exponential priority.  
  417.  *    unsigned int         :1;      Unused.  
  418.  *    unsigned int linPrio    :3;      Linear priority.  
  419.  *
  420.  *    unsigned int interFrameSpace:8;      Interframe spacing.  
  421.  *
  422.  *    unsigned int slotTimeLow    :8;      Low bits of slot time.  
  423.  *
  424.  *    unsigned int numRetries    :4;      Number of transmit retries.  
  425.  *    unsigned int         :1;      Unused.      
  426.  *    unsigned int slotTimeHigh    :3;      High bits of the slot time.  
  427.  *
  428.  *    unsigned int pad        :1;      Padding.  
  429.  *    unsigned int bitStuff    :1;      Hdlc bit stuffing.  
  430.  *    unsigned int crc16        :1;      CRC 16 bits or 32.  
  431.  *    unsigned int noCrcInsert    :1;      No crc insertion.  
  432.  *    unsigned int xmitOnNoCarr  :1;      Transmit even if no carrier sense.  
  433.  *    unsigned int manch    :1;      Manchester or NRZ encoding.  
  434.  *    unsigned int noBroadcast    :1;      Disable broadcasts.  
  435.  *    unsigned int promisc    :1;      Promiscuous mode.  
  436.  *
  437.  *    unsigned int collDetectSrc    :1;      Collision detect source.  
  438.  *    unsigned int cdFilter    :3;      Collision detect filter bits.  
  439.  *    unsigned int carrSenseSrc    :1;      Carrier sense source.  
  440.  *    unsigned int carrSenseFilter:3;    
  441.  *
  442.  *    unsigned int minFrameLength:8;      Minimum frame length.  
  443.  *
  444.  *    unsigned int        :8;      Unused.  
  445.  *} NetIEConfigureCB;
  446.  */
  447.  
  448. typedef struct {
  449.     NetIECommandBlock    cmdBlock;    /* The command block. */
  450.     unsigned short    bits[6];
  451. } NetIEConfigureCB;
  452.  
  453. #define ByteCount                 0x0404
  454. #define FifoLimit                 0x0c04
  455. #define SaveBadFrames             0x1001
  456. #define SrdyArdy                  0x1101
  457. #define ExcLoopback               0x1801
  458. #define IntLoopback               0x1901
  459. #define Preamble                  0x1a02
  460. #define AtLoc                     0x1c01
  461. #define AddrLen                   0x1d03
  462. #define BackOff                   0x2001
  463. #define ExpPrio                   0x2103
  464. #define LinPrio                   0x2503
  465. #define InterFrameSpace           0x2808
  466. #define SlotTimeLow               0x3008
  467. #define NumRetries                0x3804
  468. #define SlotTimeHigh              0x3d03
  469. #define Pad                       0x4001
  470. #define BitStuff                  0x4101
  471. #define Crc16                     0x4201
  472. #define NoCrcInsert               0x4301
  473. #define XmitOnNoCarr              0x4401
  474. #define Manch                     0x4501
  475. #define NoBroadcast               0x4601
  476. #define Promisc                   0x4701
  477. #define CollDetectSrc             0x4801
  478. #define CdFilter                  0x4903
  479. #define CarrSenseSrc              0x4c01
  480. #define CarrSenseFilter           0x4d03
  481. #define MinFrameLength            0x5008
  482.  
  483.  
  484. /*
  485.  * Transmit command block. 
  486.  */
  487.  
  488. typedef struct {
  489.     unsigned int bits[1];        /* See below. */
  490.     short      nextCmdBlock;        /* The offset of the next command 
  491.                        block */
  492.     short      bufDescOffset;    /* The offset of the buffer descriptor */
  493.     Net_EtherAddress  destEtherAddr;    /* The ethernet address of the 
  494.                        destination machine. */
  495.     short      type;            /* Ethernet packet type field. */
  496. } NetIETransmitCB;
  497.  
  498. /*
  499.  * The transmit command block has the following format:
  500.  *
  501.  * typedef struct {
  502.  *    unsigned int xmitDeferred    :1;      Transmission deferred.  
  503.  *    unsigned int heartBeat    :1;      Heart beat.  
  504.  *    unsigned int tooManyCollisions:1;      Too many transmit collisions.  
  505.  *    unsigned int         :1;      Unused.  
  506.  *    unsigned int numCollisions    :4;      The number of collisions 
  507.  *                       experienced  
  508.  *    unsigned int cmdDone    :1;      Command done.  
  509.  *    unsigned int cmdBusy    :1;      Command busy.  
  510.  *    unsigned int cmdOK        :1; Command completed successfully.  
  511.  *    unsigned int cmdAborted    :1;      The command aborted.  
  512.  *    unsigned int         :1;      Unused.  
  513.  *    unsigned int noCarrSense    :1;      No carrier sense.  
  514.  *    unsigned int noClearToSend    :1; Transmission unsuccessful because
  515.  *                       of loss of clear to send signal.  
  516.  *    unsigned int underRun    :1;       DMA underrun.  
  517.  *
  518.  *    unsigned int        :5;      Unused.  
  519.  *    unsigned int cmdNumber    :3;      Command number.  
  520.  *
  521.  *    unsigned int endOfList    :1;      The end of the command list.  
  522.  *    unsigned int suspend    :1;      Suspend when command completes.  
  523.  *    unsigned int interrupt    :1;      Interrupt when the command 
  524.  *    unsigned int         :5;      Unused.  
  525.  *
  526.  *    short      nextCmdBlock;          The offset of the next command 
  527.  *                       block  
  528.  *    short      bufDescOffset;      The offset of the buffer descriptor  
  529.  *    Net_EtherAddress  destEtherAddr;      The ethernet address of the 
  530.  *                       destination machine.  
  531.  *    short      type;              Ethernet packet type field.  
  532.  *} NetIETransmitCB;
  533.  */
  534.  
  535. #define XmitDeferred              0x0001
  536. #define HeartBeat                 0x0101
  537. #define TooManyCollisions         0x0201
  538. #define NumCollisions             0x0404
  539. #define CmdDone                   0x0801
  540. #define CmdBusy                   0x0901
  541. #define CmdOK                     0x0a01
  542. #define CmdAborted                0x0b01
  543. #define NoCarrSense               0x0d01
  544. #define NoClearToSend             0x0e01
  545. #define UnderRun                  0x0f01
  546. #define CmdNumber                 0x1503
  547. #define EndOfList                 0x1801
  548. #define Suspend                   0x1901
  549. #define Interrupt                 0x1a01
  550.  
  551.  
  552. /* 
  553.  * The transmit buffer descriptor.
  554.  */
  555.  
  556. typedef struct {
  557.     unsigned short bits[1];        /* See below. */
  558.     short    nextTBD;        /* Offset of the next transmit 
  559.                        buffer descriptor. */
  560.     int        bufAddr;        /* Address of buffer of data. */
  561. } NetIETransmitBufDesc;
  562.  
  563. /*
  564.  * The transmit buffer descriptor has the following format:
  565.  *
  566.  * typedef struct {
  567.  *    unsigned    int countLow    :8;      Low order 8 bits of count of bytes  
  568.  *    unsigned    int eof    :1;      Last buffer in the packet.  
  569.  *    unsigned    int        :1;      Unused.  
  570.  *    unsigned    int countHigh    :6;      High order 6 bits of the count.  
  571.  *
  572.  *    short    nextTBD;          Offset of the next transmit 
  573.  *                       buffer descriptor.  
  574.  *    int        bufAddr;          Address of buffer of data.  
  575.  *} NetIETransmitBufDesc;
  576.  */
  577.  
  578. #define CountLow                  0x0008
  579. #define Eof                       0x0801
  580. #define CountHigh                 0x0a06
  581.  
  582. /*
  583.  * The receive frame descriptor.
  584.  */
  585.  
  586. typedef struct NetIERecvFrameDesc {
  587.     unsigned int bits[1];        /* See below. */
  588.     short nextRFD;            /* Next receive frame descriptor. */
  589.     short recvBufferDesc;        /* Offset of the first receive buffer
  590.                        descriptor. */
  591.  
  592.     Net_EtherAddress destAddr;        /* Destination ethernet address. */
  593.     Net_EtherAddress srcAddr;        /* Source ethernet address. */
  594.     short      type;            /* Ethernet packet type. */
  595.     volatile struct NetIERecvFrameDesc *realNextRFD; /* The SUN address of 
  596.                                         the next receive frame descriptor. */
  597. } NetIERecvFrameDesc;
  598.  
  599. /*
  600.  * The receive frame descriptor has the following format:
  601.  *
  602.  * typedef struct NetIERecvFrameDesc {
  603.  *    unsigned int shortFrame    :1;      Was a short frame.  
  604.  *    unsigned int noEOF    :1;      No EOF (bitstuffing mode only).  
  605.  *    unsigned int         :6;      Unused.  
  606.  *
  607.  *    unsigned int done        :1;      Frame completely stored.  
  608.  *    unsigned int busy        :1;      Busy storing frame.  
  609.  *    unsigned int ok        :1;      Frame received OK  
  610.  *    unsigned int         :1;      Unused.  
  611.  *    unsigned int crcError    :1;      Received packet had a crc error  
  612.  *    unsigned int alignError    :1;      Received packet had an alignment * 
  613.  *                       error  
  614.  *    unsigned int outOfBufs    :1;      Receive unit ran out of memory  
  615.  *    unsigned int overrun    :1;      DMA overrun.  
  616.  *
  617.  *    unsigned int         :8;      Unused.  
  618.  *
  619.  *    unsigned int endOfList    :1;      End of list.  
  620.  *    unsigned int suspend    :1;      Suspend when done receiving.  
  621.  *    unsigned int         :6;      Unused.  
  622.  *
  623.  *    short nextRFD;              Next receive frame descriptor.  
  624.  *    short recvBufferDesc;          Offset of the first receive buffer
  625.  *                       descriptor.  
  626.  *
  627.  *    Net_EtherAddress destAddr;      Destination ethernet address.  
  628.  *    Net_EtherAddress srcAddr;          Source ethernet address.  
  629.  *    short      type;              Ethernet packet type.  
  630.  *    volatile struct NetIERecvFrameDesc *realNextRFD;   The SUN address of 
  631.  *                                        the next receive frame descriptor.  
  632.  *} NetIERecvFrameDesc;
  633.  */
  634.  
  635. #define ShortFrame                0x0001
  636. #define NoEOF                     0x0101
  637. #define Done                      0x0801
  638. #define Busy                      0x0901
  639. #define Ok                        0x0a01
  640. #define CrcError                  0x0c01
  641. #define AlignError                0x0d01
  642. #define OutOfBufs                 0x0e01
  643. #define Overrun                   0x0f01
  644. #define EndOfList                 0x1801
  645. #define Suspend                   0x1901
  646.  
  647. /*
  648.  * Receive buffer descriptor.
  649.  */
  650. typedef struct NetIERecvBufDesc {
  651.     unsigned short bits1[1];        /* See below. */
  652.  
  653.     short nextRBD;            /* Next receive buffer descriptor. */
  654.     int      bufAddr;            /* The address of the buffer that
  655.                        this descriptor puts its data. */
  656.  
  657.     unsigned short bits2[1];        /* See below. */
  658.     Address    realBufAddr;        /* The SUN address of the buffer 
  659.                        where this descriptor puts its data*/
  660.     volatile struct NetIERecvBufDesc *realNextRBD; /* The 6800 Address of the
  661.                                             next receive buffer descriptor. */
  662. } NetIERecvBufDesc;
  663.  
  664. /*
  665.  * The receive buffer descriptor has the following format:
  666.  *
  667.  * typedef struct NetIERecvBufDesc {
  668.  *    unsigned int countLow    :8;      Low order bits of the count of bytes
  669.  *                       in this buffer.  
  670.  *    unsigned int eof        :1;      Last buffer for this packet.  
  671.  *    unsigned int countValid    :1;      The value in the count field is 
  672.  *                       valid.  
  673.  *    unsigned int countHigh    :6;      High order bits of the count.  
  674.  *
  675.  *    short nextRBD;              Next receive buffer descriptor.  
  676.  *    int      bufAddr;          The address of the buffer that
  677.  *                       this descriptor puts its data.  
  678.  *
  679.  *    unsigned int bufSizeLow    :8;      Low order bits of amount of bytes
  680.  *                       this buffer is capable of holding  
  681.  *    unsigned int endOfList    :1;      This is the end of the RBD list.  
  682.  *    unsigned int        :1;      Unused.  
  683.  *    unsigned int bufSizeHigh    :6;      High order 6 bits of the buffer 
  684.  *                       size.  
  685.  *    Address    realBufAddr;          The SUN address of the buffer 
  686.  *                       where this descriptor puts its data 
  687.  *    volatile struct NetIERecvBufDesc *realNextRBD;   The 6800 Address of the
  688.  *                                            next receive buffer descriptor.  
  689.  *} NetIERecvBufDesc;
  690.  */
  691.  
  692. #define CountLow                  0x0008
  693. #define Eof                       0x0801
  694. #define CountValid                0x0901
  695. #define CountHigh                 0x0a06
  696.  
  697. #define BufSizeLow                0x0008
  698. #define RBDEndOfList              0x0801
  699. #define BufSizeHigh               0x0a06
  700.  
  701. /*
  702.  * The intel ethernet register.
  703.  */
  704.  
  705. typedef unsigned char NetIEControlRegister;
  706.  
  707. /*
  708.  * The intel ethernet register has the following format:
  709.  *
  710.  * typedef struct {
  711.  *    unsigned int noReset    :1;      R/W: 0 => Ethernet reset, 
  712.  *                        1 => Normal.  
  713.  *    unsigned int noLoopback    :1;      R/W: 0 => Loopback, 
  714.  *                        1 => Normal.  
  715.  *    unsigned int channelAttn    :1;      R/W: Channel Attention.  
  716.  *    unsigned int intrEnable    :1;      R/W: Interrupt enable.  
  717.  *    unsigned int         :2;      Reserved.  
  718.  *    unsigned int busError    :1;      R/O: DMA bus error.  
  719.  *    unsigned int intrPending    :1;      R/O: Got an interrupt request.  
  720.  *} NetIEControlRegister;
  721.  */
  722.  
  723. #define NoReset                   0x0001
  724. #define NoLoopback                0x0101
  725. #define ChannelAttn               0x0201
  726. #define IntrEnable                0x0301
  727. #define BusError                  0x0601
  728. #define IntrPending               0x0701
  729.  
  730. /*
  731.  * Structure to hold all state information associated with one of these
  732.  * chips.
  733.  */
  734.  
  735. typedef struct {
  736.     unsigned int    memBase;    /* Address of control block memory. */
  737.     volatile NetIESysConfPtr *sysConfPtr;
  738.                                         /* Where the system configuration
  739.                        pointer is at. */
  740.     volatile NetIEIntSysConfPtr    *intSysConfPtr;
  741.                                         /* Where the intermediate system
  742.                        configuration pointer is at. */
  743.     volatile NetIESCB    *scbPtr;    /* Pointer to system control block. */
  744.     volatile NetIECommandBlock *cmdBlockPtr;/* Head of command block list */
  745.     volatile NetIERecvFrameDesc    *recvFrDscHeadPtr; /* Head of receive frame
  746.                                             descriptor list. */
  747.     volatile NetIERecvFrameDesc    *recvFrDscTailPtr; /* Tail of receive frame
  748.                                             descriptor list. */
  749.     volatile NetIERecvBufDesc *recvBufDscHeadPtr; /* Head of receive buffer
  750.                                             descriptor list. */
  751.     volatile NetIERecvBufDesc *recvBufDscTailPtr; /* Tail of receive buffer
  752.                                             descriptor list. */
  753.     List_Links        *xmitList;    /* Pointer to the front of the list of
  754.                        packets to be transmited. */
  755.     List_Links          *xmitFreeList;    /* Pointer to a list of unused 
  756.                        transmission queue elements. */
  757.     List_Links        xmitListHdr;    /* The transmit list. */
  758.     List_Links        xmitFreeListHdr;/* The unused elements. */
  759.     volatile NetIETransmitCB *xmitCBPtr; /* Pointer to the single command block
  760.                        for transmitting packets. */
  761.     Boolean        transmitting;    /* Set if are currently transmitting a
  762.                        packet. */
  763.     Boolean        running;    /* Is the chip currently active. */
  764.     volatile NetIEControlRegister *controlReg;/* The onboard device register.*/
  765.     Net_EtherAddress    etherAddress;    /* The ethernet address in reverse
  766.                        byte order. */
  767.     char        *netIEXmitTempBuffer;    /* Buffer for pieces of a 
  768.                          * packet that are too small
  769.                          * or misaligned. */
  770.     volatile NetIETransmitBufDesc *xmitBufAddr;    /* The address of the array 
  771.                          * of buffer descriptor 
  772.                          * headers. */
  773.     Net_ScatterGather     *curScatGathPtr;  /* Pointer to scatter gather element 
  774.                        * for current packet being sent. */
  775.     Net_Interface    *interPtr;    /* Pointer back to network interface. */
  776.     Net_EtherStats    stats;        /* Performance statistics. */
  777.     Address        netIERecvBuffers[NET_IE_NUM_RECV_BUFFERS]; /* Buffers.*/
  778.     char                loopBackBuffer[NET_ETHER_MAX_BYTES]; /* Buffer for the
  779.                           * loopback address. */
  780. } NetIEState;
  781.  
  782. /*
  783.  * XMIT_TEMP_BUFSIZE limits how big a thing can
  784.  * be and start on an odd address.
  785.  */
  786. #define XMIT_TEMP_BUFSIZE    (NET_ETHER_MAX_BYTES + 2)
  787.  
  788. /*
  789.  * Define the minimum size allowed for a piece of a transmitted packet.
  790.  * There is a minimum size because the Intel chip has problems if the pieces
  791.  * are too small.
  792.  */
  793. #define MIN_XMIT_BUFFER_SIZE    12
  794.  
  795. /*
  796.  * Buffers for output.
  797.  */
  798. extern    char    *netIEXmitFiller;
  799.  
  800. /*
  801.  * General routines.
  802.  */
  803.  
  804. extern ReturnStatus NetIEInit _ARGS_((Net_Interface *interPtr));
  805. extern ReturnStatus NetIEOutput _ARGS_((Net_Interface *interPtr, 
  806.         Address hdrPtr, Net_ScatterGather *scatterGatherPtr,
  807.         int scatterGatherLength, Boolean rpc, ReturnStatus *statusPtr));
  808. extern void NetIEIntr _ARGS_((Net_Interface *interPtr, Boolean polling));
  809. extern ReturnStatus NetIEIOControl _ARGS_((Net_Interface *interPtr, 
  810.             Fs_IOCParam *ioctlPtr, Fs_IOReply *replyPtr));
  811. extern void NetIERestart _ARGS_((Net_Interface *interPtr));
  812. extern void NetIEReset _ARGS_((Net_Interface *interPtr));
  813. extern ReturnStatus NetIEGetStats _ARGS_((Net_Interface *interPtr, 
  814.             Net_Stats *statPtr));
  815.  
  816. /*
  817.  * Routines for transmitting.
  818.  */
  819.  
  820. extern void NetIEXmitInit _ARGS_((NetIEState *statePtr));
  821. extern void NetIEXmitDone _ARGS_((NetIEState *statePtr));
  822. extern void NetIEXmitDrop _ARGS_((NetIEState *statePtr));
  823.  
  824. /*
  825.  * Routines for the command unit.
  826.  */
  827.  
  828. extern void NetIECheckSCBCmdAccept _ARGS_((volatile NetIESCB *scbPtr));
  829. extern void NetIEExecCommand _ARGS_((register volatile NetIECommandBlock *cmdPtr, NetIEState *statePtr));
  830.  
  831. /*
  832.  * Routines for the receive unit.
  833.  */
  834.  
  835. extern void NetIERecvUnitInit _ARGS_((NetIEState *statePtr));
  836. extern void NetIERecvProcess _ARGS_((Boolean dropPackets, NetIEState *statePtr));
  837.  
  838. /*
  839.  * Memory routines.
  840.  */
  841.  
  842. extern void NetIEMemInit _ARGS_((NetIEState *statePtr));
  843. extern Address NetIEMemAlloc _ARGS_((NetIEState *statePtr));
  844.  
  845. /*
  846.  * Routines to convert to addresses and offsets.
  847.  */
  848.  
  849. extern int NetIEAddrFromSUNAddr _ARGS_((int addr));
  850. extern int NetIEAddrToSUNAddr _ARGS_((int addr));
  851. extern int NetIEOffsetFromSUNAddr _ARGS_((int addr, NetIEState *statePtr));
  852. extern int NetIEOffsetToSUNAddr _ARGS_((int offset, NetIEState *statePtr));
  853. extern int NetIEShortSwap _ARGS_((int num));
  854.  
  855. extern void NetIEStatePrint _ARGS_((NetIEState *statePtr));
  856. extern void NetIEIntSysConfPtrPrint _ARGS_((volatile 
  857.         NetIEIntSysConfPtr *confPtr));
  858. extern void NetIESCBPrint _ARGS_((volatile NetIESCB *scbPtr));
  859.  
  860. #endif /* _NETIEINT */
  861.